package com.winz.cultureapp.adapter.vp;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;


import com.winz.cultureapp.fragment.WelcomeVPFragment;

import java.util.List;

/**
 * ViewPager的适配器
 */
public class WelcomeVPAdapter extends FragmentStatePagerAdapter {

    //图片资源数据
    private  List<Integer> data;

    public WelcomeVPAdapter(FragmentManager fm, List<Integer> data) {
        super(fm);
        this.data=data;
    }

    @Override
    public Fragment getItem(int position) {
        //返回自定义的HeadViewPagerFragment 设置循环效果
        return WelcomeVPFragment.getInstance(data.get(position));
    }

    /**
     * 要生成fragment的数量,直接返回数据的长度
     * @return
     */
    @Override
    public int getCount() {
        return data.size();
    }
}
